//
//  TT_DockItem.m
//  ExhibitionHall
//
//  Created by 王洋 on 2019/5/28.
//  Copyright © 2019 王洋. All rights reserved.
//

#import "TT_DockItem.h"

@implementation TT_DockItem

-(instancetype)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];

    self.backgroundColor = [UIColor clearColor];
    return self;
    
}
-(void)setTitle:(NSString *)title{
    [self setTitle:title forState:UIControlStateNormal];
    self.titleLabel.textAlignment=NSTextAlignmentCenter;
    self.titleLabel.font = [UIFont systemFontOfSize:12];
    //正常状态下是灰色
    [self setTitleColor:UIColorHex(0xf1f1f1) forState:UIControlStateNormal];
    //不可点击的时候切换文字颜色
    [self setTitleColor:UIColorHex(0x3c7ef4) forState:UIControlStateDisabled];
    //设置图片属性
    self.imageView.contentMode = UIViewContentModeScaleToFill;
}

-(void)imageSetting:(NSString *)backgroundImage selectedImage:(NSString *)selectedImage{
    self.backgroundImage=backgroundImage;
    self.selectedImage=selectedImage;
}

//设置背景图片
-(void)setBackgroundImage:(NSString *)backgroundImage{
    
    _backgroundImage=backgroundImage;
    
    [self setImage:[UIImage imageNamed:backgroundImage] forState:UIControlStateNormal];
    
}
//设置选中图片
-(void)setSelectedImage:(NSString *)selectedImage{
    _selectedImage=selectedImage;
    [self setImage:[UIImage imageNamed:selectedImage] forState:UIControlStateDisabled];
    
}
//设置图片区域
-(CGRect)imageRectForContentRect:(CGRect)contentRect{
    
    CGFloat itemW = contentRect.size.width;
    CGFloat itemH = contentRect.size.height;
    
    CGFloat  width=itemW * 0.3;
    CGFloat  height= itemH * 0.3;
    return CGRectMake(itemW * 0.35, itemH * 0.2, width, height);
}
//设置文字区域
-(CGRect)titleRectForContentRect:(CGRect)contentRect{
//    CGFloat itemW = contentRect.size.width;
    CGFloat itemH = contentRect.size.height;
    
    CGFloat  width=contentRect.size.width;
//    CGFloat  height= contentRect.size.height * 0.3;
//    CGFloat  position=contentRect.size.height*0.7;
    return CGRectMake(0, 0.6 * itemH, width, 0.2 * itemH);
}

-(void)setFrame:(CGRect)frame{
    //固定Item宽高
    frame.size=CGSizeMake(10, 10);
    [super setFrame:frame];
}

@end
